Skip to content

[PET-39] Upgrade to zod v4 (Upgrade Zod to v4 and update imports and enum references)#40

Merged
zigcccc merged 4 commits intomainfrom
PET-39-upgrade-to-zod-v4
Mar 18, 2026
Merged

[PET-39] Upgrade to zod v4 (Upgrade Zod to v4 and update imports and enum references)#40
zigcccc merged 4 commits intomainfrom
PET-39-upgrade-to-zod-v4

Conversation

@zigcccc
Copy link
Owner

@zigcccc zigcccc commented Mar 18, 2026

Summary by CodeRabbit

  • Chores

    • Updated core dependencies to latest stable versions for improved compatibility and performance.
  • Refactor

    • Updated internal code structure for consistency with new dependency versions. No changes to user-facing functionality or features.

@zigcccc zigcccc self-assigned this Mar 18, 2026
@zigcccc zigcccc added the enhancement New feature or request label Mar 18, 2026
@coderabbitai
Copy link

coderabbitai bot commented Mar 18, 2026

Walkthrough

The PR upgrades Zod from v3 to v4 and updates imports across the codebase from convex-helpers/server/zod to convex-helpers/server/zod4. It corrects all enum references from uppercase Enum property to lowercase enum property due to Zod v4's enum export changes and updates validation error field names accordingly.

Changes

Cohort / File(s) Summary
Convex Backend Models
convex/dictionary/models.ts, convex/leaderboardEntries/model.ts, convex/leaderboards/models.ts, convex/puzzleGuessAttempts/models.ts, convex/puzzles/models.ts, convex/shared/models.ts, convex/userPuzzleStatistics/models.ts, convex/users/models.ts
Updated import paths from convex-helpers/server/zod to convex-helpers/server/zod4 for zodToConvex and related helpers. In convex/users/models.ts, validation error keys also changed from "message" to "error" in nickname constraints.
Convex Backend Queries & Internal
convex/leaderboards/queries.ts, convex/notifications/queries.ts, convex/puzzleGuessAttempts/helpers.ts, convex/puzzleGuessAttempts/queries.ts, convex/puzzles/internal.ts, convex/puzzles/queries.ts, convex/shared/queries.ts, convex/userPuzzleStatistics/internal.ts, convex/userPuzzleStatistics/queries.ts, convex/users/queries.ts
Updated import paths for zid and other helpers to convex-helpers/server/zod4. Systematically replaced all enum references from uppercase Enum property (e.g., leaderboardType.Enum.private) to lowercase enum property (e.g., leaderboardType.enum.private).
Frontend Hooks
src/hooks/useDailyPuzzle/useDailyPuzzle.ts, src/hooks/useGameplaySettings/useGameplaySettings.ts, src/hooks/useLeaderboards/useLeaderboards.ts, src/hooks/usePuzzlesStatistics/usePuzzlesStatistics.test.ts, src/hooks/useTrainingPuzzle/useTrainingPuzzle.ts
Updated all enum references from uppercase Enum to lowercase enum property access (e.g., puzzleType.Enum.dailypuzzleType.enum.daily, gameplayKeyboardType.Enum.qwertygameplayKeyboardType.enum.qwerty, leaderboardType.Enum.privateleaderboardType.enum.private).
Frontend Components
src/app/(authenticated)/history/daily-challenges.tsx, src/app/(authenticated)/history/training-challenges.tsx, src/app/(authenticated)/leaderboards/all-time-leaderboard.tsx, src/app/(authenticated)/leaderboards/weekly-leaderboard.tsx, src/app/(authenticated)/play/daily-puzzle-solved.tsx, src/app/(authenticated)/play/training-puzzle-solved.tsx, src/app/(authenticated)/settings.tsx, src/app/onboard/gameplay-settings.tsx, src/app/onboard/restore-account.tsx, src/components/elements/GuessGrid/GuessGrid.tsx, src/components/elements/HistoryGrid/HistoryGrid.tsx, src/components/elements/Keyboard/Keyboard.tsx, src/constants/puzzles.ts, src/utils/words.ts
Systematically replaced enum property access from uppercase Enum to lowercase enum across all puzzle type, leaderboard type, keyboard type, and letter status references. In src/app/onboard/restore-account.tsx, validation error keys changed from "message" to "error".
Test Files
src/__tests__/leaderboards/*.test.tsx, src/__tests__/onboard/gameplay-settings.test.tsx, src/__tests__/play/*.test.tsx, src/__tests__/settings.test.tsx, src/components/elements/GuessGrid/GuessGrid.test.tsx, src/components/elements/HistoryGrid/HistoryGrid.test.tsx, src/components/elements/Keyboard/Keyboard.test.tsx, src/hooks/useDailyPuzzle/useDailyPuzzle.test.ts, src/hooks/useGameplaySettings/useGameplaySettings.test.ts, src/hooks/useLeaderboards/useLeaderboards.test.ts, src/hooks/useTrainingPuzzle/useTrainingPuzzle.test.ts, src/tests/fixtures/*
Updated all test assertions and mock data to use lowercase enum property access instead of uppercase Enum. Changes affect expected enum values in test expectations, mock return values, and fixture objects across puzzle types, leaderboard types, keyboard types, and letter statuses.
Configuration Files
package.json, eslint.config.js
Bumped zod from ^3.25.76 to ^4.3.6. In ESLint config, selectively adjusted convex/_generated/** ignore patterns between configuration blocks.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • PR #20: Dependency version bumps for convex-helpers and zod packages that enable the import path and enum casing changes in this PR.
  • PR #22: Enum usage modifications for gameplayKeyboardType and other generated enums that directly overlap with this PR's enum casing updates.
  • PR #21: Modifies convex/leaderboardEntries/model.ts alongside this PR's import path updates to that same file.

Suggested labels

dependencies, refactor

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: upgrading Zod to v4 and updating all related imports and enum references throughout the codebase.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch PET-39-upgrade-to-zod-v4
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link

🚀 Expo preview is ready!

  • Project → petka-app
  • Platforms → android, ios
  • Scheme → petkaapp
  • Runtime Version → 1.6
  • More info

Learn more about 𝝠 Expo Github Action

@coderabbitai coderabbitai bot changed the title [PET-39] Upgrade to zod v4 (@coderabbitai) [PET-39] Upgrade to zod v4 (Upgrade Zod to v4 and update imports and enum references) Mar 18, 2026
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/hooks/useDailyPuzzle/useDailyPuzzle.test.ts (1)

251-317: Consolidate duplicated “attempt is correct” tests into one case.

These three blocks are effectively the same scenario and can be merged to keep the suite focused.

♻️ Suggested cleanup
-  it('should trigger createPuzzleAttempt mutation on onSubmitAttempt action - success scenario, attempt is correct', async () => {
-    ...
-  });
-
-  it('should trigger createPuzzleAttempt mutation on onSubmitAttempt action - success scenario, attempt is correct', async () => {
-    ...
-  });
+  // Keep a single "attempt is correct" integration-style test for this flow.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/hooks/useDailyPuzzle/useDailyPuzzle.test.ts` around lines 251 - 317,
There are duplicate test cases for the "attempt is correct" success path; remove
the redundant test blocks and keep a single spec that asserts onSubmitAttempt
calls createPuzzleGuessAttempt with { userId: testUser1._id, puzzleId:
testDailyPuzzle1._id, attempt: 'spawn' }, then calls markPuzzleAsSolved with {
puzzleId: testDailyPuzzle1._id, userId: testUser1._id }, emits
captureEvent('puzzle:solved', { puzzleId: ..., userId: ..., type:
puzzleType.enum.daily }), and does not call mockToast — update the remaining
test (calling result.current.onSubmitAttempt) to have a clear unique description
and delete the duplicate test that repeats the same assertions.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/hooks/useDailyPuzzle/useDailyPuzzle.test.ts`:
- Around line 251-317: There are duplicate test cases for the "attempt is
correct" success path; remove the redundant test blocks and keep a single spec
that asserts onSubmitAttempt calls createPuzzleGuessAttempt with { userId:
testUser1._id, puzzleId: testDailyPuzzle1._id, attempt: 'spawn' }, then calls
markPuzzleAsSolved with { puzzleId: testDailyPuzzle1._id, userId: testUser1._id
}, emits captureEvent('puzzle:solved', { puzzleId: ..., userId: ..., type:
puzzleType.enum.daily }), and does not call mockToast — update the remaining
test (calling result.current.onSubmitAttempt) to have a clear unique description
and delete the duplicate test that repeats the same assertions.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4a7d76de-16a6-4c55-8abc-8b229211e3b4

📥 Commits

Reviewing files that changed from the base of the PR and between bfc6233 and 9f77263.

⛔ Files ignored due to path filters (4)
  • convex/_generated/dataModel.d.ts is excluded by !**/_generated/**
  • convex/_generated/server.d.ts is excluded by !**/_generated/**
  • convex/_generated/server.js is excluded by !**/_generated/**
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (57)
  • convex/dictionary/models.ts
  • convex/leaderboardEntries/model.ts
  • convex/leaderboards/models.ts
  • convex/leaderboards/queries.ts
  • convex/notifications/queries.ts
  • convex/puzzleGuessAttempts/helpers.ts
  • convex/puzzleGuessAttempts/models.ts
  • convex/puzzleGuessAttempts/queries.ts
  • convex/puzzles/internal.ts
  • convex/puzzles/models.ts
  • convex/puzzles/queries.ts
  • convex/shared/models.ts
  • convex/shared/queries.ts
  • convex/userPuzzleStatistics/internal.ts
  • convex/userPuzzleStatistics/models.ts
  • convex/userPuzzleStatistics/queries.ts
  • convex/users/models.ts
  • convex/users/queries.ts
  • eslint.config.js
  • package.json
  • src/__tests__/leaderboards/all-time-leaderboard.test.tsx
  • src/__tests__/leaderboards/weekly-leaderboard.test.tsx
  • src/__tests__/onboard/gameplay-settings.test.tsx
  • src/__tests__/play/daily-puzzle-solved.test.tsx
  • src/__tests__/play/training-puzzle-solved.test.tsx
  • src/__tests__/settings.test.tsx
  • src/app/(authenticated)/history/daily-challenges.tsx
  • src/app/(authenticated)/history/training-challenges.tsx
  • src/app/(authenticated)/leaderboards/all-time-leaderboard.tsx
  • src/app/(authenticated)/leaderboards/weekly-leaderboard.tsx
  • src/app/(authenticated)/play/daily-puzzle-solved.tsx
  • src/app/(authenticated)/play/training-puzzle-solved.tsx
  • src/app/(authenticated)/settings.tsx
  • src/app/onboard/gameplay-settings.tsx
  • src/app/onboard/restore-account.tsx
  • src/components/elements/GuessGrid/GuessGrid.hook.ts
  • src/components/elements/GuessGrid/GuessGrid.test.tsx
  • src/components/elements/GuessGrid/GuessGrid.tsx
  • src/components/elements/HistoryGrid/HistoryGrid.test.tsx
  • src/components/elements/HistoryGrid/HistoryGrid.tsx
  • src/components/elements/Keyboard/Keyboard.test.tsx
  • src/components/elements/Keyboard/Keyboard.tsx
  • src/constants/puzzles.ts
  • src/hooks/useDailyPuzzle/useDailyPuzzle.test.ts
  • src/hooks/useDailyPuzzle/useDailyPuzzle.ts
  • src/hooks/useGameplaySettings/useGameplaySettings.test.ts
  • src/hooks/useGameplaySettings/useGameplaySettings.ts
  • src/hooks/useLeaderboards/useLeaderboards.test.ts
  • src/hooks/useLeaderboards/useLeaderboards.ts
  • src/hooks/usePuzzlesStatistics/usePuzzlesStatistics.test.ts
  • src/hooks/useTrainingPuzzle/useTrainingPuzzle.test.ts
  • src/hooks/useTrainingPuzzle/useTrainingPuzzle.ts
  • src/tests/fixtures/leaderboards.ts
  • src/tests/fixtures/puzzleGuessAttempts.ts
  • src/tests/fixtures/puzzleStatistics.ts
  • src/tests/fixtures/puzzles.ts
  • src/utils/words.ts

@zigcccc zigcccc merged commit 43ed6d5 into main Mar 18, 2026
4 checks passed
@zigcccc zigcccc deleted the PET-39-upgrade-to-zod-v4 branch March 18, 2026 20:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant